package com.windea.study.kotlin.game.tankwar2.enums

import kotlin.random.*

enum class Direction {
	Up,
	Down,
	Left,
	Right;
	
	companion object {
		/**得到随机方法，可选需要避免的方向。*/
		fun random(avoidDirection: Direction? = null): Direction {
			val direction = enumValues<Direction>()[Random.nextInt(4)]
			if(direction == avoidDirection) return random(avoidDirection)
			return direction
		}
	}
}
